    //
//  WeiboDetailController.m
//  WeiboSpace
//
//  Created by  linan4 on 12-3-5.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "ImageViewController.h"
#import"ImageDLoader.h"

@implementation ImageViewController
@synthesize imageUrl;

- (id)InitViewWithImageUrl:(NSString*)newImageUrl {
	
		if (self = [super init]) 
		{
		  self.imageUrl = newImageUrl;
		}
		return self;
	}

- (void)viewDidUnload {
	self.imageUrl = nil;
    [super viewDidUnload];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.navigationItem.title = @"ImageWatcher";
	
	UIBarButtonItem *timeline = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply
																				target:self action:@selector(backtoTimeLine)];
	self.navigationItem.leftBarButtonItem = timeline;
	[timeline release];
	
	
	CGRect rect = CGRectMake(0, 0, 320, 480);
	imageView = [[UIImageView alloc] initWithFrame:rect];
	[self.view addSubview:imageView];
	[imageView release];
	
	//下载图片
//	ImageDLoader *imageDown = [[ImageDLoader alloc]init];
//	[imageDown getImageFromURL:imageUrl UiImage:nil delegate:self];
//	[imageDown release];

	
}

-(void) backtoTimeLine{
	
	[self.navigationController popViewControllerAnimated:YES];
}

#pragma mark ImageDLoaderDelegate
- (void)receivedImage:(NSData*)imageData sender:(ImageDLoader*)sender{
	
	if (imageData==nil||[imageData length]==0) {
		return;
	}
	
	UIImage *imageCtl = [UIImage imageWithData:imageData];
	[imageView setImage:imageCtl];
	//imageView.image = imageCtl;

}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}


- (void)dealloc {
	[imageUrl release];
    [super dealloc];
}


@end
